package org.leiyang.common.dtos;

import com.google.common.base.Objects;
import io.netty.channel.Channel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class MsgServerInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 服务端地址
     */
    private String serverAddress;

    /**
     * 服务端通信端口
     */
    private String serverPort;

    /**
     * 已经被打开的连接通道channel的ID集合
     */
    private List<String> channelIds;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MsgServerInfo that = (MsgServerInfo) o;
        return Objects.equal(getServerAddress(), that.getServerAddress()) && Objects.equal(getServerPort(), that.getServerPort());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getServerAddress(), getServerPort());
    }
}